import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:zhrs/Utils/windowsSize.dart';
import 'package:zhrs/Model/usermessage.dart';
import 'package:zhrs/mainpage/webviewpage.dart';
import 'package:zhrs/model/message.dart';
class User extends StatefulWidget
{

  Function reset;

  User({index=1,this.reset})
  {
    if(index==1)
    {
        user=new usermessage(name: "姓名:张明清",Idcard: "身份证号:310101********1111",socialcard: "社会保障卡号:A11111111",date: "日期:2019年7月",imgUrl: 'http://106.12.180.103/smartDemo/images/head-male.png');
    }
    if(index==2)
    {
        user=new usermessage(name: "姓名:李敏慧",Idcard: "身份证号:310101********2222",socialcard: "社会保障卡号:A22222222",date: "日期:2019年7月",imgUrl: 'http://106.12.180.103/smartDemo/images/head-female.png');
    }
    if(index==3)
    {
        user=new usermessage(name: "姓名:高玉怀",Idcard: "身份证号:310101********3333",socialcard: "社会保障卡号:A33333333",date: "日期:2019年7月",imgUrl: 'http://106.12.180.103/smartDemo/images/head-aged.png');
    }
  }
  int index;

  usermessage user;
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState

    return _User();
  }

}

class _User extends  State<User>
{


  @override
  Widget build(BuildContext context) {
    windowsSize.mapViewWidth = MediaQuery
        .of(context)
        .size
        .width;
    windowsSize.mapViewHeight = MediaQuery
        .of(context)
        .size
        .height;
    // TODO: implement build
    return new Container(
        //color: Colors.black12,

        // MediaQuery.removePadding(context: null, child: null),
        child:  MediaQuery.removePadding(
          removeTop: true,
          context: context,
          child: Container(
             // color: Colors.lightBlue,
             height:windowsSize.mapViewHeight ,
               child: ListView(

                     children: <Widget>[
                        Column(
                          children: <Widget>[

                            Container(
                            color: Colors.lightBlue,
                             height: windowsSize.mapViewHeight * 0.06,
                               child:  Row(
                                 children: <Widget>[
                                   Container(
                                     height:windowsSize.mapViewHeight*0.05 ,
                                     width: windowsSize.mapViewWidth*0.9,
                                     padding:EdgeInsets.only(left:30),
                                     child: Text("我的",textAlign: TextAlign.center,style: TextStyle(fontSize:20 ,color: Colors.white,decoration: TextDecoration.none),),
                                   ),
                                   Container(
                                     height:windowsSize.mapViewHeight*0.06 ,
                                     width: windowsSize.mapViewWidth*0.1,
                                     child:Icon(Icons.settings,
                                       // size: windowsSize.mapViewHeight * 0.05,
                                       color: Colors.white,) ,
                                   ),
                                 ],
                               ),
                            ),


                          Container(

                            height: windowsSize.mapViewHeight -windowsSize.mapViewHeight * 0.15 ,
                            child: ListView(
                              children: <Widget>[
                                Container(
                                  child: Column(
                                    children: <Widget>[
                                      Container(
                                        width: windowsSize.mapViewWidth,
                                        height: 200,
                                         color: Colors.lightBlue,
                                        child: Row(
                                          children: <Widget>[
                                            Container(
                                              color: Colors.lightBlue ,
                                              width: windowsSize.mapViewWidth*0.87,
                                              child: Center(
                                                child:
                                                new ClipRRect(
                                                  borderRadius: const BorderRadius.all(const Radius.circular(10.0)),
                                                  child:
                                                 Container(
                                                  color: Colors.white30 ,
                                                  width: windowsSize.mapViewWidth*0.80,
                                                  height: 160,
                                                  child: Column
                                                    (
                                                    mainAxisAlignment: MainAxisAlignment.spaceAround,
                                                    children: <Widget>[
                                                      Row(
                                                        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                                                        children: <Widget>[
                                                          new ClipRRect(
                                                            borderRadius: const BorderRadius.all(const Radius.circular(360.0)),
                                                            child:Container(

                                                              height: windowsSize.mapViewWidth *
                                                                  0.20,
                                                              width: windowsSize.mapViewWidth *
                                                                  0.20,
                                                              child:  new Image.network(//加载网络图片
                                                                widget.user.imgUrl,
                                                                repeat: ImageRepeat.noRepeat,//图片重复方式
                                                                // fit: BoxFit.fill,
                                                              ),
                                                            ),
                                                          ),
                                                          Container(
                                                            child: Column(
                                                              crossAxisAlignment: CrossAxisAlignment.start,
                                                              children: <Widget>[
                                                                Text(widget.user.name,style: TextStyle(fontSize: 15,color: Colors.white),),
                                                                Container(height: 10,),
                                                                Text(widget.user.Idcard,style: TextStyle(color: Colors.white),),
                                                                Container(height: 3,),
                                                                Text(widget.user.socialcard,style: TextStyle(color: Colors.white),),
                                                                Container(height: 3,),
                                                                Text(widget.user.date,style: TextStyle(color: Colors.white),),
                                                              ],
                                                            ),
                                                          )
                                                        ],
                                                      ),
                                                      Container(
                                                        child: Row(
                                                          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                                                          children: <Widget>[
                                                              Icon(Icons.stars,color: Colors.white30,size: 30,),
                                                            Container(
                                                              color: Colors.white30,
                                                              width: windowsSize.mapViewWidth*0.65 ,
                                                              height: 10,
                                                            )
                                                          ],
                                                        ),
                                                      )
                                                    ],
                                                  ),
                                                ) ,
                                                )
                                              ),
                                            ),
                                            Container(
                                             // color: Colors.red ,
                                              height: 160,
                                              child: Center(
                                                child:Container(
                                                  width: windowsSize.mapViewWidth*0.13,
                                                  height: 160,
                                                  child: Column(
                                                    mainAxisAlignment:MainAxisAlignment.end,
                                                    crossAxisAlignment:CrossAxisAlignment.start,
                                                      children: <Widget>[
                                                         ClipRRect(
                                                           borderRadius: const BorderRadius.all(const Radius.circular(360.0)),
                                                           child: Container(
                                                                 height:   windowsSize.mapViewWidth*0.10,
                                                                 width: windowsSize.mapViewWidth*0.10,

                                                             color: Colors.white30,
                                                             child:Center(
                                                               child:
                                                                  new IconButton(
                                                             // Use the FontAwesomeIcons class for the IconData
                                                             icon: new Icon(FontAwesomeIcons.qrcode,color: Colors.white,size: 16,),
                                                               onPressed: () {

                                                              // Navigator.push(context,  MaterialPageRoute(builder:(context) =>Webviewpage(url: "https://www.dzsbk.cn/smartDemo/page/user/dzsbk_sfewm_09.html",)));
                                                                           widget.reset(url:"https://www.dzsbk.cn/smartDemo/page/user/dzsbk_sfewm_09.html");
                                                             }
                                                           )
                                                               // Icon(FontAwesomeIcons.qrcode,color: Colors.white,size: 16,),
                                                             ),
                                                           ),
                                                         ),
                                                        Container(
                                                          height: 10,
                                                        ),
                                                        ClipRRect(
                                                          borderRadius: const BorderRadius.all(const Radius.circular(360.0)),
                                                          child: Container(
                                                            height:   windowsSize.mapViewWidth*0.10,
                                                            width: windowsSize.mapViewWidth*0.10,
                                                            color: Colors.white30,
                                                            child:Center(
                                                              child:  Icon(Icons.border_color,color: Colors.white,size: 16,),
                                                            ),
                                                          ),
                                                        ),
                                                    ],
                                                  ),
                                                ) ,
                                              ),
                                            )
                                          ],
                                        ),
                                      )
                                    ],
                                  ),
                                ),

                                Column(
                                  children: medicalmessagelist.map((val)
                                  {
                                    if(val.index==0)
                                      {
                                        return Column(
                                          children: <Widget>[
                                            Container(
                                              decoration: new BoxDecoration(  border: new Border.all(color: Colors.black12, width: 0.5),),
                                              child: new ListTile(
                                                leading:  new Image.network(//加载网络图片
                                                  val.imgUrl,
                                                  width: 25,
                                                  height: 25,
                                                  repeat: ImageRepeat.noRepeat,//图片重复方式
                                                  // fit: BoxFit.fill,
                                                ),
                                                title: Text(val.title),
                                                trailing: new Icon(Icons.arrow_forward_ios, size: 15,),
                                                onTap: ()
                                                {

                                                    if(val.Url!=null)
                                                    {
                                                      if(val.Url!="")
                                                        {

                                                          widget.reset(url:val.Url);
                                                          //Navigator.push(context, new MaterialPageRoute(

                                                           // builder :(context)=>new Webviewpage(url:val.Url ,),
                                                          //));
                                                        }
                                                      else
                                                        {
                                                          confirmCupertinoDialogs(context, "确定要退出?");
                                                        }
                                                    }
                                                    else
                                                    {
                                                      showCupertinoDialogs(context, "建设中,敬请期待...");
                                                    }

                                                },
                                              ),
                                            ),
                                            Opacity(
                                              opacity: 0.2,
                                              child:Container(
                                                height: 10,
                                                color: Colors.black12,
                                              ) ,
                                            ),
                                          ],
                                        );
                                      }

                                    return   Container(
                                      decoration: new BoxDecoration(  border: new Border.all(color: Colors.black12, width: 0.5),),
                                      child: new ListTile(
                                        leading:  new Image.network(//加载网络图片
                                          val.imgUrl,
                                          width: 25,
                                          height: 25,
                                          repeat: ImageRepeat.noRepeat,//图片重复方式
                                          // fit: BoxFit.fill,
                                        ),
                                        title: Text(val.title),
                                        trailing: new Icon(Icons.arrow_forward_ios, size: 15,),
                                        onTap: ()
                                        {
                                            if(val.Url!=null)
                                            {
                                              if(val.Url!="")
                                              {
                                                widget.reset(url:val.Url);
                                              //  Navigator.push(context, new MaterialPageRoute(

                                               //   builder :(context)=>new Webviewpage(url:val.Url ,),
                                              //  ));
                                              }
                                              else
                                              {
                                                confirmCupertinoDialogs(context, "确定要退出?");
                                              }
                                            }
                                            else
                                            {
                                              showCupertinoDialogs(context, "建设中,敬请期待...");
                                            }
                                        },
                                      ),
                                    );

                                  }).toList(),

                                ),
                               Opacity(
                                  opacity: 0.2,
                                  child:Container(
                                   height: 40,
                                   color: Colors.black12,
                                  ),
                               )
                              ],
                            ),
                          )
                          ]
                        )],
               )
          )
        )
    );
  }
}